package com.lpf.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.lpf.service.HelloService;
import org.apache.skywalking.apm.toolkit.trace.ActiveSpan;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.stereotype.Component;

@Service
@Component
public class DefaultHelloService implements HelloService {

    @Override
    public String say(String name) throws Exception {
        Thread.sleep(2000);
        return "hello" + name;
    }

    @Trace(operationName = "default-trace-method")
    @Override
    public void traceMethod() throws InterruptedException {
        Thread.sleep(1000);
        ActiveSpan.tag("trace-method", String.valueOf(System.currentTimeMillis()));
        ActiveSpan.info("traceMethod info Message");
        System.out.println(TraceContext.traceId()); // 打印Trace ID
    }

}

